<?php
class Welcome extends FrontAction{
	
	function index(){
		$db = $this->getDB();
		
		$news_img = $db->get_assoc("select news.id,news.title,news.content,news_images.imgurl,news_images.imgdesc from news left join news_images on news.id = news_images.newsid where  lang = '$this->lang'");
		$this->data['news_img'] = $news_img;
		
		$news = $db->query_assoc("select id,title from news where lang = '$this->lang' order by createtime desc limit 0,3");
		$this->data['news'] = $news;		
		
		$product_imgs = $db->query_assoc("select product.id,product.pname,product.pdesc,product_images.imgurl,product_images.imgdesc from product left join product_images on product.id = product_images.pid where  product.lang = '$this->lang' order by product.createtime desc limit 0,2  ");
		$this->data['product_imgs'] = $product_imgs;
		
		$aboutus = $db->query_assoc("select * from mapinfo where keyid = 'aboutus' and lang = '$this->lang'");
		$this->data['aboutus'] = $aboutus;
		
		$this->data['lang'] = $this->lang;

		template('index',$this->data);
	}
	
	function setlang($lang){
		setSession('lang', $lang);
		header('location:/index.php');
	}
}